package 共享锁;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo2 {
    public static void main(String[] args) throws InterruptedException {
        final CountDownLatch latch = new CountDownLatch(10);
        for(int i=0; i<10; i++){
            final int j = i +1;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("第" + j + "名");
                    latch.countDown();
                }
            }).start();
        }
        latch.await();
        System.out.println("比赛结束");
    }
}
